<?php
/**
 * @package WordPress
 * @subpackage produccion musical
 */

#

#
 
#
$locale = get_locale();
#
$locale_file = TEMPLATEPATH . "/languages/$locale.php";
#
if ( is_readable($locale_file) )
#
 require_once($locale_file);
#
 
#
// Get the page number
#
function get_page_number() {
#
    if ( get_query_var('paged') ) {
#
        print ' | ' . __( 'Page ' , 'produccion musical') . get_query_var('paged');
#
    }
#
} // end get_page_number
	
	add_editor_style();

	add_theme_support( 'post-thumbnails' );
	

	load_theme_textdomain( 'produccion musical', TEMPLATEPATH . '/languages' );

$content_width = 450;

add_theme_support( 'automatic-feed-links' );
     
	 // This theme uses wp_nav_menu() in one location.
	register_nav_menus( array(
		'Header Menu' => __( 'Header Menu', 'produccion musical' ),
	) );


if ( function_exists('register_sidebar') ) {
	register_sidebar(array(
		'before_widget' => '<li id="%1$s" class="widget %2$s">',
		'after_widget' => '</li>',
		'before_title' => '<h2 class="widgettitle">',
		'after_title' => '</h2>',
	));
}

/**
 * count for trackback, pingback, comment, pings
 *
 * embed like this:
 * fb_comment_type_count('pings');
 * fb_comment_type_count('comment');
 * http://code.google.com/p/wp-basis-theme/
 */

 function fb_get_comment_type_count( $type='all', $zero = false, $one = false, $more = false, $post_id = 0) {
                global $cjd_comment_count_cache, $id, $post;

                if ( !$post_id )
                        $post_id = $post->ID;
                if ( !$post_id )
                        return;

                if ( !isset($cjd_comment_count_cache[$post_id]) ) {
                        $p = get_post($post_id);
                        $p = array($p);
                        fb_update_comment_type_cache($p);
                }
                ;
                if ( $type == 'pingback' || $type == 'trackback' || $type == 'comment' )
                        $count = $cjd_comment_count_cache[$post_id][$type];
                elseif ( $type == 'pings' )
                        $count = $cjd_comment_count_cache[$post_id]['pingback'] + $cjd_comment_count_cache[$post_id]['trackback'];
                else
                        $count = array_sum((array) $cjd_comment_count_cache[$post_id]);

                return apply_filters('fb_get_comment_type_count', $count);
        }

if ( !function_exists('fb_update_comment_type_cache') ) {
        function fb_update_comment_type_cache($queried_posts) {
                global $cjd_comment_count_cache, $wpdb;

                if ( !$queried_posts )
                        return $queried_posts;

                foreach ( (array) $queried_posts as $post )
                        if ( !isset($cjd_comment_count_cache[$post->ID]) )
                                $post_id_list[] = $post->ID;

                if ( $post_id_list ) {
                        $post_id_list = implode(',', $post_id_list);

                        foreach ( array('', 'pingback', 'trackback') as $type ) {
                                $counts = $wpdb->get_results("SELECT ID, COUNT( comment_ID ) AS ccount
                                                        FROM $wpdb->posts
                                                        LEFT JOIN $wpdb->comments ON ( comment_post_ID = ID AND comment_approved = '1' AND comment_type='$type' )
                            WHERE (post_status = 'publish' OR (post_status = 'inherit' AND post_type = 'attachment')) AND ID IN ($post_id_list)
                                                        GROUP BY ID");

                                if ( $counts ) {
                                        if ( '' == $type )
                                                $type = 'comment';
                                        foreach ( $counts as $count )
                                                $cjd_comment_count_cache[$count->ID][$type] = $count->ccount;
                                }
                        }
                }

                return $queried_posts;
        }

        add_filter('the_posts', 'fb_update_comment_type_cache');
}

if (!function_exists('produccion_musical_menu')) :

	function produccion_musical_menu(){ ?>
		<ul id="menu" class"headerfix">
            <li <?php if ( is_single() || is_home()) { echo 'class="current_page_item"'; } ?>><a href="<?php echo bloginfo('url'); ?>"><?php _e('Home','produccion musical'); ?></a></li>
            <?php wp_list_pages('echo=1&sort_column=menu_order&depth=1&title_li='); ?>
        </ul>
<?php      		
	} 
	
endif;

/** Added by Steven L of ISomehowHate.com and modifieed by Andrei on 07.4
| Fixes an issue that can occur when a user has magic_quotes switched to on.
| This ensures no \'s are added to the code which causes Google Adsense and perhaps other things to fail.
| Changes Made to Existing Code: Added stripslash_check to the update_option functions
**/

function stripslash_check($variable) {
        $stripped = stripslashes($variable);
        return $stripped;
}


/**
 * Smart cache-busting
 * http://toscho.de/2008/frisches-layout/#comment-13
 */

/*if ( !function_exists('fb_css_cache_buster') ) {
        function fb_css_cache_buster($info, $show) {
                if ($show == 'stylesheet_url') {

                        // Is there already a querystring? If so, add to the end of that.
                        if (strpos($pieces[1], '?') === false) {
                                return $info . "?" . filemtime(WP_CONTENT_DIR . $pieces[1]);
                        } else {
                                $morsels = explode("?", $pieces[1]);
                                return $info . "&" . filemtime(WP_CONTENT_DIR . $morsles[1]);
                        }
                } else {
                        return $info;
                }
        }

        add_filter('bloginfo_url', 'fb_css_cache_buster', 9999, 2);
}*/

// CANONICAL COMMENTS

function canonical_for_comments() {
global $cpage, $post;
if ( $cpage > 1 ) :
echo "\n";
echo "<link rel='canonical' href='";
echo get_permalink( $post->ID );
echo "' />\n";
endif;
}

// SIDEBOX

function lw_show_sidebox(){
global $lw_sidebox_settings;

switch ($lw_sidebox_settings)
{
case "Enabled":
default:
echo "<div class=\"comm_date\"><span class=\"data\"><span class=\"j\">".get_the_time('j')."</span>".get_the_time('M/y')."</span><span class=\"nr_comm\">";
echo "<a class=\"nr_comm_spot\" href=\"".get_permalink()."#comments\">";
if(!comments_open()) _e('Off','produccion musical'); else echo fb_get_comment_type_count('comment');
echo "</a></span></div>\n";
break;

case "Disabled":
break;

case "Show only in posts":
if(is_single()){
echo "<div class=\"comm_date\"><span class=\"data\"><span class=\"j\">".get_the_time('j')."</span>".get_the_time('M/y')."</span><span class=\"nr_comm\">";
echo "<a class=\"nr_comm_spot\" href=\"".get_permalink()."#comments\">";
if(!comments_open()) _e('Off','produccion musical'); else echo fb_get_comment_type_count('comment')."</a>";
echo "</span></div>\n";
}
break;

case "Show only date":
/* START ONLY DATE */
echo "<div class=\"comm_date only_date\"><span class=\"data\"><span class=\"j\">".get_the_time('j')."</span>".get_the_time('M/y')."</span><span class=\"nr_comm\">";
echo "</span></div>\n";
/* END ONLY DATE */
break;

case "Last two options together":
/* START  LAST TWO */
if(is_single()){
echo "<div class=\"comm_date only_date\"><span class=\"data\"><span class=\"j\">".get_the_time('j')."</span>".get_the_time('M/y')."</span><span class=\"nr_comm\">";
echo "</span></div>\n";
}
/* END LAST TWO */
break;

} // end switch
} // end function

function lw_sidebar(){
global $lw_sidebar_settings, $lw_layout_settings;
if($lw_layout_settings=="Wider"){
switch ($lw_sidebar_settings)
{
case "One sidebar":
default:
break;

case "Two sidebars":
default;
break;



} // end switch
}// end if
} // end function


function lw_simple_date(){
global $lw_sidebox_settings;
if($lw_sidebox_settings == "Disabled"){
echo "<div class=\"simple_date\">".__('Posted on','produccion musical')." ".get_the_time(__('F j, Y','produccion musical'))."</div>";
}
}

?>
